package com.huawang.mdesign.model.service.util;

import org.jetbrains.annotations.Nullable;

import java.util.Optional;

/**
 * @author cdl
 */
public class ThreadLocalUtil {

    private ThreadLocalUtil() {}

    private static final ThreadLocal<Boolean> CONTAINER = new InheritableThreadLocal<>();

    public static void set(Boolean flag) {
        Optional.ofNullable(flag).ifPresent(e -> CONTAINER.set(flag));
    }

    @Nullable
    public static Boolean get() {
        return CONTAINER.get();
    }

    public static void remove() {
        CONTAINER.remove();
    }
}
